package com.cote.douhahou.pretloan.any.data.akomapalendtask;

import android.content.Context;
import android.text.TextUtils;

import com.cote.douhahou.pretloan.any.data.akomapalendhttp.AkomapalendASReqstManger;
import com.cote.douhahou.pretloan.any.data.akomapalendlogger.AkomapalendASLger;
import com.cote.douhahou.pretloan.any.data.akomapalendservices.AkomapalendASInstAppsIfo;
import com.cote.douhahou.pretloan.beans.AkomapalendASRequestPms;
import com.cote.douhahou.pretloan.url.AkomapalendPaths;
import com.cote.douhahou.pretloan.utils.AkomapaLendUtil;

import java.util.function.Supplier;


public class AkomapalendASDevcAppsTsk implements Supplier<String> {

    private final static String TAG = "ASDeviceAppListTask";

    private final String mTaskId;
    private final Context mContext;

    public AkomapalendASDevcAppsTsk(Context context, String taskId) {
        this.mContext = context;
        this.mTaskId = taskId;
    }

    @Override
    public String get() {
        
        AkomapalendASLger.logd(TAG, TAG + " Processing...");

        
        if (TextUtils.isEmpty(AkomapalendPaths.PATH_APPLIST)) {
            return mTaskId + "";
        }

        String infoBeans = "";
        infoBeans = AkomapalendASInstAppsIfo.gtZipString(mContext);
        if (TextUtils.isEmpty(infoBeans)) {
            
            AkomapalendASLger.logd(TAG, "获取app列表信息出错:Data is Null");
            return mTaskId + "";
        }

        AkomapalendASRequestPms netPms = new AkomapalendASRequestPms();
        netPms.etALkomapalend(infoBeans);
//        String result = new Gson().toJson(netParams).trim();
        String result = netPms.toEnptParam(AkomapalendPaths.PATH_APPLIST);

        
        String url = AkomapaLendUtil.commonUrl();// + ASBuilder.P_APL;
        new AkomapalendASReqstManger.Builder().stReqId(this.mTaskId).stUrl(url).seBody(result).build().doPtRqst();

        return mTaskId + "";
    }

}
